<?php
  
  
  require "../framework.php";  
  
  
  backup::createBackup();
  
  
  
 /* $backupFolder = config::$projectPath."/backup";
  file::createFolder($backupFolder, false);
  
  foreach (db::getData("_table") as $data) {
      
        $csvExport = new csv_export();
      $csvExport->table = $data['table_name'];
      $csvExport->baseDir = false;
      $csvExport->csvFilename = $backupFolder."/{$data['table_name']}.csv";
      $csvExport->exportCsv();
      
  }
  
  
   $csvExport = new csv_export();
      $csvExport->table = "_table";
      $csvExport->baseDir = false;
      $csvExport->csvFilename = $backupFolder."/_table.csv";
      $csvExport->exportCsv();
  
   $csvExport = new csv_export();
      $csvExport->table = "_table_field";
      $csvExport->baseDir = false;
      $csvExport->csvFilename = $backupFolder."/_table_field.csv";
      $csvExport->exportCsv();    */
  
  
  
  
  
  
  
  //xml_config::importXmlConfig()
  
  
 /* $xmlDatabase = new xml_database();
  
  
  //$xmlDatabase->xmlTable2
  
  
  
  
  
  $xmlDatabase->readXmlFile(config::$projectPath."/db/db.xml", false);
  
  
  
  //$test = $xmlDatabase->getTable();
  
  
  
  //$xmlDatabase->xmlTable
  
  
  //$a = $xmlDatabase->getTable();
  
  
  
  
  
  
  
  foreach ($xmlDatabase->getTableList() as $table) {
      
      
                    
      
      
      //echo $table."<br>";
      
      
      $xmlTable = $xmlDatabase->getTable($table);

      
      
      foreach ($xmlTable->xmlField as $fieldItem) {
          
          echo $fieldItem->fieldName;
          if (($fieldItem->fieldType = "image") or ($fieldItem->fieldType = "file")) {
              
              
              $imagePath = config::$projectPath."/db_file/{$xmlTable->tableName}";
              file::createFolder($imagePath, false);
  
              
              // create resize path
              $resizePath = config::$distributionPath."/code/upload";
              
              file::createFolder($resizePath, false);
              file::createFolder($resizePath."/".$table, false);
              
              
              $resize = $fieldItem->imageResize;
              $resize = general::stringToArray($resize);
              
              
              foreach ($resize as $resizeItem) {
                    file::createFolder($resizePath."/".$table."/".$resizeItem, false);
              }
          }
      }
      
      
      
      
      
      
      
      
      
      
      
      
      if ($xmlTable->scaffolding) {
      
      
      echo "scffolding ".$xmlTable->tableName;
      
      
      $csvExport = new csv_export();
      $csvExport->table = $xmlTable->tableName;
      $csvExport->baseDir = true;
      $csvExport->csvFilename = "/tmp/{$xmlTable->tableName}.csv";
      
      $csvExport->exportCsv();
      
      
      
      
      
      foreach ($xmlTable->xmlField as $fieldItem) {
          
          
          echo $fieldItem->fieldName;
          
      }
      
      
      
      
      
      }
      
      
      
      
  }    */
  
  
  
  
  
  
  
  
  
  
?>
